package com.yiwyn.Structural.facade;

import lombok.Data;

/**
 * 门面模式 demo
 */
public class FacadeDemo {

    public static void main(String[] args) {
        SmartHomeFacade facade = new SmartHomeFacade();
        facade.cdHome();

        facade.exitHome();
    }

    @Data
    static class SmartHomeFacade {
        private LightSystem lightSystem = new LightSystem();
        private AirSystem airSystem = new AirSystem();
        private AudioSystem audioSystem = new AudioSystem();

        public void cdHome() {
            lightSystem.turnOn();
            airSystem.turnOn();
            audioSystem.turnOn();
        }

        public void exitHome() {
            lightSystem.turnOff();
            airSystem.turnOff();
            audioSystem.turnOff();
        }

    }

    static class LightSystem {

        public void turnOn() {
            System.out.println("灯光打开");
        }

        public void turnOff() {
            System.out.println("灯光闭关");
        }
    }

    static class AirSystem {
        public void turnOn() {
            System.out.println("空调打开");
        }

        public void turnOff() {
            System.out.println("空调闭关");
        }
    }

    static class AudioSystem {
        public void turnOn() {
            System.out.println("声音打开");
        }

        public void turnOff() {
            System.out.println("声音闭关");
        }
    }


}
